#!/usr/bin/env node

const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
const { ListToolsRequestSchema } = require('@modelcontextprotocol/sdk/types.js');

console.error('=== SIMPLE MCP TEST STARTING ===');

const server = new Server(
  {
    name: 'simple-test',
    version: '1.0.0',
  },
  {
    capabilities: {
      tools: {},
    },
  }
);

server.setRequestHandler(ListToolsRequestSchema, async () => {
  console.error('=== TOOLS LIST REQUEST RECEIVED ===');
  return {
    tools: [
      {
        name: 'test_tool',
        description: 'A simple test tool',
        inputSchema: {
          type: 'object',
          properties: {
            message: {
              type: 'string',
              description: 'Test message'
            }
          }
        }
      }
    ]
  };
});

async function main() {
  console.error('=== INITIALIZING TRANSPORT ===');
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error('=== MCP SERVER RUNNING ===');
}

main().catch(error => {
  console.error('=== FATAL ERROR ===');
  console.error(error);
  process.exit(1);
});